package com.ruoyi.tjfx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tjfx.domain.TbTjfxQy12yltj;
import com.ruoyi.tjfx.service.ITbTjfxQy12yltjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业近12月用量统计Controller
 *
 * @author ruoyi
 * @date 2023-11-12
 */
@RestController
@RequestMapping("/tjfx/qy12yltj")
public class TbTjfxQy12yltjController extends BaseController
{
    @Autowired
    private ITbTjfxQy12yltjService tbTjfxQy12yltjService;

    /**
     * 查询企业近12月用量统计列表
     */
    @PreAuthorize("@ss.hasPermi('tjfx:qy12yltj:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbTjfxQy12yltj tbTjfxQy12yltj)
    {
        startPage();
        List<TbTjfxQy12yltj> list = tbTjfxQy12yltjService.selectTbTjfxQy12yltjList(tbTjfxQy12yltj);
        return getDataTable(list);
    }

    /**
     * 导出企业近12月用量统计列表
     */
    @PreAuthorize("@ss.hasPermi('tjfx:qy12yltj:export')")
    @Log(title = "企业近12月用量统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbTjfxQy12yltj tbTjfxQy12yltj)
    {
        List<TbTjfxQy12yltj> list = tbTjfxQy12yltjService.selectTbTjfxQy12yltjList(tbTjfxQy12yltj);
        ExcelUtil<TbTjfxQy12yltj> util = new ExcelUtil<TbTjfxQy12yltj>(TbTjfxQy12yltj.class);
        util.exportExcel(response, list, "企业近12月用量统计数据");
    }

    /**
     * 获取企业近12月用量统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('tjfx:qy12yltj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbTjfxQy12yltjService.selectTbTjfxQy12yltjById(id));
    }

    /**
     * 新增企业近12月用量统计
     */
    @PreAuthorize("@ss.hasPermi('tjfx:qy12yltj:add')")
    @Log(title = "企业近12月用量统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbTjfxQy12yltj tbTjfxQy12yltj)
    {
        return toAjax(tbTjfxQy12yltjService.insertTbTjfxQy12yltj(tbTjfxQy12yltj));
    }

    /**
     * 修改企业近12月用量统计
     */
    @PreAuthorize("@ss.hasPermi('tjfx:qy12yltj:edit')")
    @Log(title = "企业近12月用量统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbTjfxQy12yltj tbTjfxQy12yltj)
    {
        return toAjax(tbTjfxQy12yltjService.updateTbTjfxQy12yltj(tbTjfxQy12yltj));
    }

    /**
     * 删除企业近12月用量统计
     */
    @PreAuthorize("@ss.hasPermi('tjfx:qy12yltj:remove')")
    @Log(title = "企业近12月用量统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbTjfxQy12yltjService.deleteTbTjfxQy12yltjByIds(ids));
    }
}
